﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">

</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <script type="text/javascript" src="/Scripts/ExtTimeOut.js"></script>
    <script type="text/javascript" src="/Scripts/ExtRequiredFieldPluins.js"></script>
    <form id="Form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Window ID="ChangePasswordWin" runat="server" Closable="false" Resizable="false"
        Height="160" Icon="ApplicationForm" Title="修改密码" Draggable="false" Width="300"
        Modal="true" Layout="FormLayout" Padding="5">
        <Items>
            <ext:TextField ID="txtOldPassword" runat="server" InputType="Password" FieldLabel="旧密码"
                AllowBlank="false" BlankText="旧密码不能为空." AnchorHorizontal="100%" />
            <ext:TextField ID="txtNewPassword" runat="server" InputType="Password" FieldLabel="新密码"
                AllowBlank="false" BlankText="新密码不能为空." AnchorHorizontal="100%" />
            <ext:TextField ID="txtRePassword" runat="server" InputType="Password" FieldLabel="重复密码"
                AllowBlank="false" BlankText="重复密码不能为空." AnchorHorizontal="100%" />
        </Items>
        <Buttons>
            <ext:Button ID="btnLogin" runat="server" Text="确认" Icon="Accept">
                <Listeners>
                    <Click Handler="
                            if (!#{txtOldPassword}.validate() || !#{txtNewPassword}.validate() || !#{txtRePassword}.validate()) {
                                Ext.Msg.alert('错误','密码都不能为空!');
                                return false; 
                            }else if(#{txtNewPassword}.getValue() != #{txtRePassword}.getValue()){
                                Ext.Msg.alert('错误','两次密码输入不一致!');
                                return false;
                            }" />
                </Listeners>
                <DirectEvents>
                    <Click Url="/Account/ChangePassword/" Timeout="60000" CleanRequest="true" Method="POST" Before="Ext.Msg.wait('正在保存...', '提示');"
                        Failure="Ext.Msg.show({
                           title:   '保存失败',
                           msg:     result.errorMessage,
                           buttons: Ext.Msg.OK,
                           icon:    Ext.MessageBox.ERROR
                        });" Success="Ext.Msg.show({
                           title:   '保存成功',
                           msg:     '密码修改成功',
                           buttons: Ext.Msg.OK
                        });">
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="btnCancel" runat="server" Text="清空" Icon="Cancel">
                <Listeners>
                    <Click Handler="#{txtOldPassword}.setValue('');#{txtNewPassword}.setValue('');#{txtRePassword}.setValue('')"/>
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    </form>
</body>
</html>
